﻿using Newtonsoft.Json;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;

namespace uTorrentExtractor.Utilities
{
    public class Serializer<T> where T : ISerializable
    {
        public Serializer()
        {
        }

        public void SerializeObject(string filename, T objectToSerialize)
        {
            File.WriteAllText(filename, JsonConvert.SerializeObject(objectToSerialize));
        }

        public T DeserializeObject(string filename)
        {
            return JsonConvert.DeserializeObject<T>(File.ReadAllText(filename));
        }
    }
}
